package com.rc.saas.tenant.service.recharge;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rc.saas.tenant.mapper.recharge.RechargeOrderMapper;
import com.rc.saas.tenant.model.recharge.RechargeOrder;
import com.rc.saas.tenant.search.recharge.RechargeOrderSearch;
import com.rc.saas.tenant.vo.order.ChargeStatisticsResult;
import com.rc.saas.tenant.vo.recharge.ExportRechargeOrderVo;
import com.rc.saas.tenant.vo.recharge.RechargeOrderExportVo;
import com.rc.saas.tenant.vo.recharge.RechargeOrderResultVo;
import com.rc.saas.tenant.vo.recharge.RechargeOrderStatisticsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by sven on 2018-04-17
 */
@Service
public class RechargeOrderServiceImpl implements RechargeOrderService {
    @Autowired
    private RechargeOrderMapper rechargeOrderMapper;

    @Override
    public RechargeOrderMapper getMapper() {
        return rechargeOrderMapper;
    }

    @Override
    public PageInfo<RechargeOrderResultVo> searchByCondition(RechargeOrderSearch rechargeOrderSearch) {
        PageHelper.startPage(rechargeOrderSearch.getOffset(), rechargeOrderSearch.getLimit());
        List<RechargeOrderResultVo> orderResults = rechargeOrderMapper.searchByCondition(rechargeOrderSearch);
        return new PageInfo<RechargeOrderResultVo>(orderResults);
    }

    @Override
    public List<ExportRechargeOrderVo> exportRechargeOrder(RechargeOrderSearch rechargeOrderSearch) {
        return rechargeOrderMapper.exportRechargeOrder(rechargeOrderSearch);
    }

    @Override
    public PageInfo<RechargeOrderResultVo> listPageRechargeOrderDetail(RechargeOrderSearch rechargeOrderSearch) {
        PageHelper.startPage(rechargeOrderSearch.getOffset(), rechargeOrderSearch.getLimit());
        List<RechargeOrderResultVo> orderResults = rechargeOrderMapper.listPageRechargeOrderDetail(rechargeOrderSearch);
        return new PageInfo<RechargeOrderResultVo>(orderResults);
    }

    @Override
    public RechargeOrderStatisticsVo selectRechargeOrderStatistics(RechargeOrderSearch rechargeOrderSearch) {
        return rechargeOrderMapper.selectRechargeOrderStatistics(rechargeOrderSearch);
    }

    @Override
    public List<RechargeOrderExportVo> rechargeOrderExport(RechargeOrderSearch rechargeOrderSearch) {
        return rechargeOrderMapper.rechargeOrderExport(rechargeOrderSearch);
    }

    @Override
    public List<ChargeStatisticsResult> listRechargeStatistics(List<Long> idList) {
        return rechargeOrderMapper.listRechargeStatistics(idList);
    }

    @Override
    public RechargeOrder selectByRechargeOrderNum(String orderNum) {
        return rechargeOrderMapper.selectByRechargeOrderNum(orderNum);
    }
}
